<template>
  <el-dropdown
    trigger="click"
    @command="handleSetSize"
  >
    <div>
      <span class="iconfont icon-zitidaxiao" />
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item
        v-for="item of sizeOptions"
        :key="item.value"
        :disabled="size===item.value"
        :command="item.value"
      >
        {{
          item.label }}
      </el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Vue from 'vue';
import {Dropdown, DropdownItem, DropdownMenu} from "element-ui";
Vue.use(Dropdown);
Vue.use(DropdownMenu);
Vue.use(DropdownItem);
/**
 * 全局文字尺寸选择
 * @author maolin
 */
export default {
  data () {
    return {
      sizeOptions: [
        // { label: this.$t('navbar.size.default'), value: 'default' },
        { label: this.$t('navbar.size.medium'), value: 'medium' },
        { label: this.$t('navbar.size.small'), value: 'small' },
        { label: this.$t('navbar.size.mini'), value: 'mini' }
      ]
    };
  },
  computed: {
    size () {
      return this.$store.getters.size;
    }
  },
  methods: {
    /**
     * 设置尺寸
     * @param {string} size 尺寸(medium/small/mini)
     * @public
     */
    handleSetSize (size) {
      this.$ELEMENT.size = size;
      this.$store.dispatch('app/setSize', size);
      // this.refreshView()
      // this.$message({
      //   message: '切换字体尺寸成功',
      //   type: 'success'
      // })
      window.location.reload();
    },
  }

};
</script>
